//
//  WJLastViewController.m
//  WJBSApp
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 王景伟. All rights reserved.
//
//  这个页面的网址  user-id是上个页面传入 + 关注的页面
//
// 头像: http://api.budejie.com/api/api_open.php?&a=profile&c=user&userid=9779590
//帖子: http://s.budejie.com/topic/user-topic/9779590/1/desc/bs0315-iphone-4.2/0-20.json?
//分享:http://s.budejie.com/topic/share-topic/9779590/bs0315-iphone-4.2/0-20.json?
// 评论:http://s.budejie.com/comment/user-comment/9779590/bs0315-iphone-4.2/0-20.json?
// 本页面是关注的最终界面

#import "WJLastViewController.h"

#import "WJEssAndNewBaseCell.h"

#import "WJLastModel.h"

#import "WJEssAndNewModel.h"

#import "WJEssAndNewPLVC.h"

#import "WJDataManager.h"

#import "WJ_TJDY_VC.h"

@interface WJLastViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) WJBaseTableView *tableView;

@property (nonatomic,strong) WJBaseView *touView;
// 上面的图片
@property (nonatomic,strong) WJBaseImageView *backgroundImageView;
// 头像
@property (nonatomic,strong) WJBaseImageView *headerImageView;
// 性别
@property (nonatomic,strong) WJBaseImageView *sexImageView;

@property (nonatomic,strong) WJEssAndNewLable *nameLable;

@property (nonatomic,strong) WJHotLable *djLable;

@property (nonatomic,strong) WJHotLable *jifenLable;

@property (nonatomic,strong) WJHotLable *gzLable;

@property (nonatomic,strong) WJHotLable *fsLable;

@property (nonatomic,strong) WJEssAndNewButton *leftButton;

@property (nonatomic,strong) WJEssAndNewButton *middenButton;

@property (nonatomic,strong) WJEssAndNewButton *rightButton;

@property (nonatomic,strong) WJBaseLable *leftLable;

@property (nonatomic,strong) UIVisualEffectView *visualView;
// 存放下面的数据
@property (nonatomic,strong) NSMutableArray *array;
// 存放header数据
@property (nonatomic,strong) WJLastModel *model;

@property (nonatomic,retain) NSNumber *np;

@property (nonatomic,assign) NSInteger presentNumber;

@property (nonatomic,assign) BOOL isExist;

@end

@implementation WJLastViewController

static NSString *const LastCell = @"LastCell";

-(void)dealloc
{
    [_userID release];
    [_userName release];
    [_tableView release];
    [_touView release];
    [_backgroundImageView release];
    [_headerImageView release];
    [_sexImageView release];
    [_nameLable release];
    [_djLable release];
    [_jifenLable release];
    
    [_gzLable release];
    [_fsLable release];
    [_leftButton release];
    [_middenButton release];
    [_rightButton release];
    [_leftLable release];
    [_array release];
    [_model release];
    [_np release];
    self.tableView.delegate = nil;
    self.tableView.dataSource = nil;
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.array = [NSMutableArray array];
    
    [self createView];
    
    [self createHeadView];
    
    [self createData];
    
    [self headerAndFotter];
    
}

//每次进来都要执行
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    self.navigationController.navigationBarHidden = NO;
}


- (void)createView
{
    
    self.tableView = [[WJBaseTableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 49) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.contentInset = UIEdgeInsetsMake(HEIGHT *2/5 + 110 , 0, 0, 0);
    [self.tableView registerClass:[WJEssAndNewBaseCell class] forCellReuseIdentifier:LastCell];
    [_tableView release];
    
    self.backgroundImageView = [[WJBaseImageView alloc]initWithFrame:CGRectMake(0, - HEIGHT *2/5 - 110, WIDTH , HEIGHT *2/5)];
    [self.tableView addSubview:self.backgroundImageView];
    [_backgroundImageView release];
    
#pragma mark - 毛玻璃效应
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *visualView =  [[UIVisualEffectView alloc]initWithEffect:effect];
    visualView.frame = self.backgroundImageView.frame;
    [self.tableView addSubview:visualView];
    self.visualView = visualView;
    [visualView release];
    
#pragma mark - 点击头像 可以 水波纹
    
    self.headerImageView = [[WJBaseImageView alloc]initWithFrame:CGRectMake(10, - 110 - WIDTH / 10 - 5, WIDTH / 5+10, WIDTH / 5 + 10)];
    self.headerImageView.layer.cornerRadius = WIDTH / 10 + 5;
    self.headerImageView.layer.masksToBounds = YES;
    self.headerImageView.backgroundColor = [UIColor orangeColor];
    [self.tableView addSubview:self.headerImageView];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    self.headerImageView.userInteractionEnabled = YES;
    [self.headerImageView addGestureRecognizer:tap];
    [_headerImageView release];
    
    self.sexImageView = [[WJBaseImageView alloc]initWithFrame:CGRectMake(30 +  WIDTH / 5, - 110 - 30, 25, 25)];
    self.sexImageView.layer.cornerRadius = 25/2;
    self.sexImageView.layer.masksToBounds = YES;
    [self.tableView addSubview:self.sexImageView];
    [_sexImageView release];
    
    self.nameLable = [[WJEssAndNewLable alloc]initWithFrame:CGRectMake(55 +  WIDTH / 5, - 110 - 30, WIDTH - 55 -  WIDTH / 5, 25)];
    self.nameLable.backgroundColor = [UIColor clearColor];
    self.nameLable.textColor = [UIColor whiteColor];
    [self.tableView addSubview:self.nameLable];
    [_nameLable release];
    
    self.djLable = [[WJHotLable alloc]initWithFrame:CGRectMake(30 +  WIDTH / 5, -100, 100, 20)];
    [self.tableView addSubview:self.djLable];
    self.djLable.backgroundColor = [UIColor clearColor];
    [_djLable release];
    
    self.jifenLable = [[WJHotLable alloc]initWithFrame:CGRectMake(30 +  WIDTH / 5, -70, 100, 20)];
    [self.tableView addSubview:self.jifenLable];
    self.jifenLable.backgroundColor = [UIColor clearColor];
    [_jifenLable release];
    
    self.gzLable = [[WJHotLable alloc]initWithFrame:CGRectMake(WIDTH - 120, -100, 50, 20)];
    [self.tableView addSubview:self.gzLable];
    self.gzLable.backgroundColor = [UIColor clearColor];
    self.gzLable.textAlignment = 1;
    [_gzLable release];
    
    WJHotLable *lable1 = [[WJHotLable alloc]initWithFrame:CGRectMake(WIDTH - 120, -70, 50, 20)];
    lable1.text = @"关注";
    lable1.textAlignment = 1;
    lable1.backgroundColor = [UIColor clearColor];
    [self.tableView addSubview:lable1];
    [lable1 release];
    
    self.fsLable = [[WJHotLable alloc]initWithFrame:CGRectMake(WIDTH - 70, -100, 50, 20)];
    [self.tableView addSubview:self.fsLable];
    self.fsLable.backgroundColor = [UIColor clearColor];
    self.fsLable.textAlignment = 1;
    [_fsLable release];
    
    WJHotLable *lable = [[WJHotLable alloc]initWithFrame:CGRectMake(WIDTH - 70, -70, 50, 20)];
    lable.text = @"粉丝";
    lable.backgroundColor = [UIColor clearColor];
    lable.textAlignment = 1;
    [self.tableView addSubview:lable];
    [lable release];
    
#pragma mark - button 的默认点击效果
    
    self.leftLable = [[WJBaseLable alloc]initWithFrame:CGRectMake(0, -40, WIDTH, 40)];
    [self.tableView addSubview:self.leftLable];
    self.leftLable.textAlignment = 1 ;
    [_leftLable release];
    
    //    self.leftButton = [WJEssAndNewButton buttonWithTitle:nil frame:CGRectMake(0, -40, WIDTH / 3, 38) target:self action:@selector(leftAction1:)];
    //    [self.tableView addSubview:self.leftButton];
    //
    //    self.middenButton = [WJEssAndNewButton buttonWithTitle:nil frame:CGRectMake(WIDTH / 3, -40, WIDTH / 3, 38) target:self action:@selector(middenAction1:)];
    //    [self.tableView addSubview:self.middenButton];
    //
    //    self.rightButton = [WJEssAndNewButton buttonWithTitle:nil frame:CGRectMake(WIDTH * 2 / 3, -40, WIDTH / 3, 38) target:self action:@selector(rightAction1:)];
    //    [self.tableView addSubview:self.rightButton];
}

#pragma mark - 水波纹
- (void)tap:(UITapGestureRecognizer *)tap{
    //
    CATransition *transition = [CATransition animation];
    // 设置动画的类型
    transition.type = @"rippleEffect";
    // 设置动画时长
    transition.duration = 1;
    // 设置重复次数
    transition.repeatCount = 2;
    // 把动画添加到imageView的layer上.
    [self.headerImageView.layer addAnimation:transition forKey:@"transition"];
}


- (void)createHeadView
{
    
    self.touView = [[WJBaseView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 64)];
    [self.view addSubview:self.touView];
    [_touView release];
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(100, 24, WIDTH - 200, 40)];
    lable.text = self.userName;
    lable.textAlignment = 1 ;
    lable.textColor = [UIColor redColor];
    [self.touView addSubview:lable];
    [lable release];
    
    WJBaseButton *button = [WJBaseButton buttonWithTitle:nil frame:CGRectMake(20, 30, 50, 30) target:self action:@selector(tjLeftAction)];
    button.backgroundColor = [UIColor clearColor];
    [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick@3x副本.png"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"navigationButtonReturn@3x副本.png"] forState:UIControlStateHighlighted];
    [self.touView addSubview:button];
    
    //#warning +关注 需要判断啊  在数据库里面  要是有就显示 取消关注
    WJEssAndNewButton *belowButton = [WJEssAndNewButton buttonWithType:UIButtonTypeCustom];
    belowButton.frame = CGRectMake(0, HEIGHT - 49, WIDTH, 49);
    belowButton.titleLabel.font = [UIFont systemFontOfSize:20];
    self.isExist = [[WJDataManager shareFMDB] isExistUserID:self.userID];
    
    if (self.isExist) { //也就是存在
        
        [belowButton setTitle:@"取消关注" forState:0];
        [belowButton setTitleColor:[UIColor grayColor] forState:0];
        
    }else{  //也就是不存在
        
        [belowButton setTitleColor:[UIColor redColor] forState:0];
        [belowButton setTitle:@"+关注" forState:0];
    }
    
    [belowButton addTarget:self action:@selector(addFollow:) forControlEvents:1<<6];
    [self.view addSubview:belowButton];
}


- (void)tjLeftAction
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WJEssAndNewBaseCell *cell = [tableView dequeueReusableCellWithIdentifier:LastCell];
    cell.model = self.array[indexPath.row];
    
    __block typeof(self) weakSelf = self;
    cell.clickComment = ^(WJEssAndNewModel *model){
        
        NSLog(@"点击了评论");
        
        WJEssAndNewPLVC *vc = [[WJEssAndNewPLVC alloc]init];
        
        vc.model = model;
        
        [weakSelf.navigationController pushViewController:vc animated:YES];
        
        [vc release];
    };
    cell.tagsVC.tagBlock = ^(NSInteger ID,NSString *name){
        
        WJ_TJDY_VC *vc = [[WJ_TJDY_VC alloc]init];
        
        vc.theme_id = ID;
        
        vc.title = name;
        
        [weakSelf.navigationController pushViewController:vc animated:YES];
        [vc release];
    };
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WJEssAndNewModel *model = self.array[indexPath.row];
    return model.cellHeight;
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if ([scrollView isEqual:self.tableView]) {
        CGFloat y = self.tableView.contentOffset.y + HEIGHT * 2 / 5 + 110 + 20;
        self.touView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:y /200];
        if (y < 0) {
            self.backgroundImageView.frame = CGRectMake(y/2,y- HEIGHT * 2 / 5 - 110, WIDTH-y, -y+ HEIGHT * 2 / 5);
            self.visualView.alpha = -y / 200;
            self.visualView.frame = self.backgroundImageView.frame;
        }else{
            
            self.backgroundImageView.frame =CGRectMake(0,y/4- HEIGHT *2/5 - 110, WIDTH, HEIGHT * 2 / 5);
        }
        
    }
}



#pragma mark - 如何让刷新啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- (void)headerAndFotter
{
    self.tableView.mj_header = [MJRefreshHeader headerWithRefreshingBlock:^{
        
        [self createLeftData];
        
    }];
    
    [self.tableView.mj_header beginRefreshing];
    
    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        
        [self loadMoreLeftData];
    }];
}

- (void)createData
{
    NSString *headerUrl = [NSString stringWithFormat:@"http://api.budejie.com/api/api_open.php?&a=profile&c=user&userid=%@",self.userID];
    [WJNetTool GET:headerUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
        
        NSDictionary *dic = resuposeObject;
        
        NSDictionary *dataDic = dic[@"data"];
        
        
        WJLastModel *model = [[WJLastModel alloc]initWithDic:dataDic];
        self.model = model;
        
        [self.backgroundImageView sd_setImageWithURL:[NSURL URLWithString:model.background_image]];
        
        [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.profile_image]];
        
        if ([model.sex isEqualToString:@"m"]) {
            self.sexImageView.image = [UIImage imageNamed:@"Profile_manIcon@3x"];
            self.sexImageView.backgroundColor = [UIColor blueColor];
        }else{
            self.sexImageView.image = [UIImage imageNamed:@"Profile_womanIcon@3x"];
            self.sexImageView.backgroundColor = [UIColor redColor];
        }
        
        self.djLable.text = [NSString stringWithFormat:@"等级:%ld",(long)model.level];
        
        self.jifenLable.text = [NSString stringWithFormat:@"积分:%ld",(long)model.credit];
        
        self.gzLable.text = model.follow_count;
        
        self.fsLable.text = model.fans_count;
        
        self.nameLable.text = model.username;
        
        self.leftLable.text =[NSString stringWithFormat:@"我的帖子:%ld",(long)model.tiezi_count];
        
        [self.tableView reloadData];
        
        
    } failure:^(NSError *error) {}];
}


- (void)createLeftData
{
    NSString *leftUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/user-topic/%@/1/desc/bs0315-iphone-4.2/0-20.json?",self.userID];
    [WJNetTool GET:leftUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
        
        NSDictionary *dic = resuposeObject;
        
        if (dic[@"info"][@"np"] == nil) return;
        
        NSArray *array = dic[@"list"];
        
        self.np = dic[@"info"][@"np"];
        
        [self.array removeAllObjects];
        
        for (NSDictionary *dic in array) {
            
            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
            [self.array addObject:model];
            [model release];
        }
        
        [self.tableView reloadData];
        [self.tableView.mj_header endRefreshing];
        
    } failure:nil];
    
    
}

- (void)loadMoreLeftData
{
    [self.tableView.mj_header endRefreshing];
    
    if ([self.np isKindOfClass:[NSNull class]] || self.np == nil)
    {
        self.tableView.mj_header.hidden = YES;
        [self.tableView.mj_footer endRefreshingWithNoMoreData];
        return;
    }
    
    NSString *leftUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/user-topic/%@/1/desc/bs0315-iphone-4.2/%@-20.json?",self.userID,self.np];
    
    [WJNetTool GET:leftUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
        
        
        NSDictionary *dic = resuposeObject;
        
        if(![dic[@"list"] isKindOfClass:[NSArray class]])
        {
            self.tableView.mj_header.hidden = YES;
            [self.tableView.mj_footer endRefreshingWithNoMoreData];
            return;
        }
        NSArray *array = dic[@"list"];
        
        self.np = dic[@"info"][@"np"];
        
        for (NSDictionary *dic in array) {
            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
            [self.array addObject:model];
            [model release];
        }
        
        [self.tableView reloadData];
        
        [self.tableView.mj_footer endRefreshing];
        
    } failure:^(NSError *error) {}];
}


#pragma mark - 添加关注啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
- (void)addFollow:(WJEssAndNewButton *)button
{
    // ID 和Name
    NSLog(@"添加数据库啊啊啊啊啊啊啊啊啊啊啊啊");
    NSString *string = button.titleLabel.text;
    if ([string isEqualToString:@"取消关注"]) { // 执行取消关注 也就是删除
        
        [button setTitle:@"+关注" forState:0];
        [button setTitleColor:[UIColor redColor] forState:0];
        [[WJDataManager shareFMDB] deleteWith:self.userID];
        
    }else{
        [button setTitle:@"取消关注" forState:0];
        [button setTitleColor:[UIColor grayColor] forState:0];
        [[WJDataManager shareFMDB] insertWithID:self.model.id username:self.model.username tiezi_count:self.model.tiezi_count follow_count:self.model.follow_count profile_image:self.model.profile_image];
    }
    
}




























- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

//#pragma mark - 三个按钮的点击方法  其中有的值为空
//
//- (void)leftAction1:(WJBaseButton *)button
//{
//    self.presentNumber = 1;
//
//    [UIView animateWithDuration:0.5 animations:^{
//
//        [self.leftButton setTitleColor:[UIColor redColor] forState:0];
//
//        [self.middenButton setTitleColor:[UIColor grayColor] forState:0];
//
//        [self.rightButton setTitleColor:[UIColor grayColor] forState:0];
//
//        self.leftLable.frame = CGRectMake(40, -2, WIDTH / 3-80 , 2);
//    }];
//
//    [self createLeftData];
//
//}
//
//- (void)middenAction1:(WJBaseButton *)button
//{
//    self.presentNumber = 2;
//
//    [UIView animateWithDuration:0.5 animations:^{
//        [self.leftButton setTitleColor:[UIColor grayColor] forState:0];
//
//        [self.middenButton setTitleColor:[UIColor redColor] forState:0];
//
//        [self.rightButton setTitleColor:[UIColor grayColor] forState:0];
//
//        self.leftLable.frame = CGRectMake(WIDTH / 3 + 40, -2, WIDTH / 3-80 , 2);
//
//    }];
//
//    [self createMiddenData];
//
//}
//
//- (void)rightAction1:(WJBaseButton *)button
//{
//    self.presentNumber = 3;
//    [UIView animateWithDuration:0.5 animations:^{
//        [self.leftButton setTitleColor:[UIColor grayColor] forState:0];
//
//        [self.middenButton setTitleColor:[UIColor grayColor] forState:0];
//
//        [self.rightButton setTitleColor:[UIColor redColor] forState:0];
//
//        self.leftLable.frame = CGRectMake(WIDTH * 2 / 3 + 40, -2, WIDTH / 3 - 80 , 2);
//
//    }];
//
//    [self createRightData];
//
//}


//#pragma mark - 如何让刷新啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
//- (void)headerAndFotter
//{
//    NSLog(@"%ld",self.presentNumber);
//
//    if (self.presentNumber == 1) {
//
//        self.tableView.mj_header = [MJRefreshHeader headerWithRefreshingBlock:^{
//
//            [self createLeftData];
//
//        }];
//
//        self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//
//            NSLog(@"左面:%@",self.np);
//
//            [self loadMoreLeftData];
//        }];
//
//    }else if (self.presentNumber == 2 ){
//
//        self.tableView.mj_header = [MJRefreshHeader headerWithRefreshingBlock:^{
//
//            [self.tableView.mj_header beginRefreshing];
//
//            [self createMiddenData];
//        }];
//
//        self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//
//            NSLog(@"中间:%@",self.np);
//
//            [self loadMoreMiddenData];
//        }];
//
//    }else if (self.presentNumber == 3){
//
//        self.tableView.mj_header = [MJRefreshHeader headerWithRefreshingBlock:^{
//
//            [self createRightData];
//        }];
//
//        self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//
//            NSLog(@"右面:%@",self.np);
//
//            [self loadMoreRightData];
//        }];
//
//    }
//
//    NSLog(@"%ld",self.presentNumber);
//
//}

//- (void)createLeftData
//{
//    NSString *leftUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/user-topic/%@/1/desc/bs0315-iphone-4.2/0-20.json?",self.userID];
//    [WJNetTool GET:leftUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//
//        NSDictionary *dic = resuposeObject;
//
//        if (dic[@"info"][@"np"] == nil) return;
//
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//        [self.array removeAllObjects];
//
//        for (NSDictionary *dic in array) {
//
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        self.presentNumber = 1;
//        [self.tableView reloadData];
//        [self.tableView.mj_header endRefreshing];
//
//    } failure:nil];
//
//
//}
//
//- (void)createMiddenData
//{
//    NSString *middenUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/share-topic/%@/bs0315-iphone-4.2/0-20.json?",self.userID];
//    [WJNetTool GET:middenUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//
//        NSDictionary *dic = resuposeObject;
//
//        NSLog(@"%@",dic[@"info"][@"np"]);
//
//        if (dic[@"info"][@"np"] == nil) return;
//
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//        [self.array removeAllObjects];
//
//        for (NSDictionary *dic in array) {
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        self.presentNumber = 2;
//        [self.tableView reloadData];
//        [self.tableView.mj_header endRefreshing];
//
//    } failure:nil];
//
//
//}
//
//- (void)createRightData
//{
//    NSString *rightUrl = [NSString stringWithFormat:@"http://s.budejie.com/comment/user-comment/%@/bs0315-iphone-4.2/0-20.json?",self.userID];
//    [WJNetTool GET:rightUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//
//        NSDictionary *dic = resuposeObject;
//
//        if (dic[@"info"][@"np"] == nil) {
//          return;
//        }
//
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//        [self.array removeAllObjects];
//
//        for (NSDictionary *dic in array) {
//
//            NSDictionary *newdic = dic[@"topic"];
//
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:newdic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        self.presentNumber = 3;
//        [self.tableView reloadData];
//        [self.tableView.mj_header endRefreshing];
//    } failure:nil];
//
//
//}
//
//
//
//- (void)loadMoreLeftData
//{
//    [self.tableView.mj_header endRefreshing];
//
//    if ([self.np isKindOfClass:[NSNull class]] || self.np == nil)
//    {
//        self.tableView.mj_header.hidden = YES;
//        [self.tableView.mj_footer endRefreshingWithNoMoreData];
//        return;
//    }
//
//    NSString *leftUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/user-topic/%@/1/desc/bs0315-iphone-4.2/%@-20.json?",self.userID,self.np];
//
//    [WJNetTool GET:leftUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//
//
//        NSDictionary *dic = resuposeObject;
//
//        if(![dic[@"list"] isKindOfClass:[NSArray class]])
//        {
//            self.tableView.mj_header.hidden = YES;
//            [self.tableView.mj_footer endRefreshingWithNoMoreData];
//            return;
//        }
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//        for (NSDictionary *dic in array) {
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        [self.tableView reloadData];
//
//        [self.tableView.mj_footer endRefreshing];
//
//    } failure:^(NSError *error) {}];
//}
//
//
//- (void)loadMoreMiddenData
//{
//    [self.tableView.mj_header endRefreshing];
//
//    if ([self.np isKindOfClass:[NSNull class]] || self.np == nil)
//    {
//        self.tableView.mj_header.hidden = YES;
//        [self.tableView.mj_footer endRefreshingWithNoMoreData];
//        return;
//    }
//
//    NSString *middenUrl = [NSString stringWithFormat:@"http://s.budejie.com/topic/share-topic/%@/bs0315-iphone-4.2/%@-20.json?",self.userID,self.np];
//
//    [WJNetTool GET:middenUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//
//        NSDictionary *dic = resuposeObject;
//
//        if(![dic[@"list"] isKindOfClass:[NSArray class]])
//        {
//            self.tableView.mj_header.hidden = YES;
//            [self.tableView.mj_footer endRefreshingWithNoMoreData];
//            return;
//        }
//
//
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//
//        for (NSDictionary *dic in array) {
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        [self.tableView reloadData];
//
//
//        [self.tableView.mj_footer endRefreshing];
//
//
//
//    } failure:^(NSError *error) {}];
//
//
//
//}
//
//- (void)loadMoreRightData
//{
//    [self.tableView.mj_header endRefreshing];
//
//    if ([self.np isKindOfClass:[NSNull class]] || self.np == nil)
//    {
//        self.tableView.mj_header.hidden = YES;
//        [self.tableView.mj_footer endRefreshingWithNoMoreData];
//        return;
//    }
//
//    NSString *rightUrl = [NSString stringWithFormat:@"http://s.budejie.com/comment/user-comment/%@/bs0315-iphone-4.2/%@-20.json?",self.userID,self.np];
//
//    [WJNetTool GET:rightUrl body:nil header:nil response:WJJSON success:^(id resuposeObject) {
//        NSDictionary *dic = resuposeObject;
//
//        if(![dic[@"list"] isKindOfClass:[NSArray class]])
//        {
//            self.tableView.mj_header.hidden = YES;
//            [self.tableView.mj_footer endRefreshingWithNoMoreData];
//            return;
//        }
//
//
//        NSArray *array = dic[@"list"];
//
//        self.np = dic[@"info"][@"np"];
//
//        for (NSDictionary *dic in array) {
//            WJEssAndNewModel *model = [[WJEssAndNewModel alloc]initWithDic:dic];
//            [self.array addObject:model];
//            [model release];
//        }
//
//        [self.tableView reloadData];
//
//        [self.tableView.mj_footer endRefreshing];
//
//    } failure:^(NSError *error) {}];
//}
//
@end
